package com.maxd.modules.selfshop.merchants.controller;

import com.maxd.adapter.IgnoreSecurity;
import com.maxd.error.Result;
import com.maxd.modules.selfshop.merchants.entity.SelfMargin;
import com.maxd.modules.selfshop.merchants.service.SelfMarginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城保证金",tags={"自营商城保证金"})
@RequestMapping(value = "/self/margin")
public class SelfMarginController {
    @Autowired
    private SelfMarginService service;

    @IgnoreSecurity
    @GetMapping("/list")
    @ApiOperation("总后台列表")
    public Result findAll(Integer page, Integer size, @RequestParam(required = false) String storeName) {
        return service.findAll(page, size, storeName);
    }

    @IgnoreSecurity
    @GetMapping("/storeList")
    @ApiOperation("商家端列表")
    public Result storeList(Integer page, Integer size, Long storeId) {
        return service.storeList(page, size, storeId);
    }

    @IgnoreSecurity
    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @IgnoreSecurity
    @PostMapping("/save")
    @ApiOperation("添加")
    public Result saveBody(@RequestBody SelfMargin entity) {
        return service.saveBody(entity);
    }

    @IgnoreSecurity
    @PostMapping("/update")
    @ApiOperation("修改")
    public Result updateBody(@RequestBody SelfMargin entity) {
        return service.updateBody(entity);
    }

    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(Long id) {
        return service.delete(id);
    }

    @IgnoreSecurity
    @PostMapping("/marginList")
    @ApiOperation("保证金选项")
    public Result marginList() {
        return service.marginList();
    }

    @IgnoreSecurity
    @GetMapping("/income")
    @ApiOperation("保证金收入统计")
    public Result income(@ApiParam("data") @RequestParam String data, @ApiParam("way： 1年 2月 3日") @RequestParam int way) {
        return service.income(data, way);
    }

}
